package homework2;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;

public class Test {
	public static void main(String[] args) {
		Teacher teacher = new Teacher("aa",20,2.0);
		Teacher teacher2 = new Teacher("bb",30,3.0);
		System.out.println(teacher.compareTo(teacher2));
		HashSet<Teacher> hashSet = new HashSet<Teacher>();
		hashSet.add(teacher);
		hashSet.add(teacher2);
		ArrayList<Teacher> arrayList = new ArrayList<Teacher>(hashSet);
		Collections.sort(arrayList,new ByAge());
		System.out.println(arrayList);
		Collections.sort(arrayList,new BySalary());
		System.out.println(arrayList);
	}
}	
class ByAge implements Comparator<Teacher>{

	@Override
	public int compare(Teacher o1, Teacher o2) {
		// TODO Auto-generated method stub
		return -(o1.getAge()-o2.getAge());
	}
	
}

class BySalary implements Comparator<Teacher>{

	@Override
	public int compare(Teacher o1, Teacher o2) {
		// TODO Auto-generated method stub
		return -(int)(o1.getSalary()-o2.getSalary());
	}
	
}
